<%@ page import="com.lianzheng.util.PageVO" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%--
  Created by IntelliJ IDEA.
  User: ChadZhao
  Date: 12-3-2
  Time: 下午1:29
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>顺序管理</title>

    <style type="text/css">
        <!--
        .tr0 { }

        .tr1 { background-color: #f4f4f4; }

        body,td,th {
            font-size: 14px;
            color: #666666;
        }
        .form { width:99%; padding:5px;}
        .form th { text-align:right; font-weight:bold; padding:5px;}
        .form td { text-align:left; padding:5px;}
        .listinput { border:1px solid #ccc; padding:3px; background-image:url(<c:url value='/images/listinputbg.gif'/>); width:200px;height:24px;}
        .select1  { border:1px solid #ccc; padding:3px;}
        .button { background-image:url(<c:url value='/images/butbg.gif'/>); height:30px; line-height:30px; color:#FFFFFF; font-weight:bold; border:0px; cursor:hand;}
        a:link { font-size: 12px; color: #333333; text-decoration: none; font-family: "微软雅黑";}
        a:visited{ font-size: 12px; color: #333333; text-decoration: none; font-family: "微软雅黑";}
        a:hover {color:#666666; font-family: "微软雅黑";}
        -->
    </style>
</head>
<body onload="parent._setHeight()">
<form method="post">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div style='float:left'> <img height="14" src="<c:url value='/frame/book1.gif'/>" width="20" />&nbsp;顺序管理 </div>
      <div style='float:right;padding-right:8px;'>
        <!--  //保留接口  -->
      </div></td>
  </tr>
  <tr>
    <td height="1" background="<c:url value='/frame/sp_bg.gif'/>" style='padding:0px'></td>
  </tr>
</table>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="form">
        <tr style="height:20px;">
            <th nowrap>
                所属版块：
            </th>
            <td><s:select name="partType" id="partType" theme="simple" cssStyle="width:190px;" cssClass="select1"
list="#{'1':'信息宣传->廉政头条','2':'信息宣传->图片新闻','3':'信息宣传->要闻速递','4':'信息宣传->廉情动态','5':'信息宣传->年度工作',
'7':'信息宣传->公告平台','40':'互动交流->专题交流','41':'互动交流->热点讨论','8':'廉政大讲堂->图片新闻','10':'廉政大讲堂->教育视线','14':'廉政大讲堂->经验推广','12':'廉政大讲堂->正反典型->勤廉风采','38':'廉政大讲堂->正反典型->案件聚焦',
'9':'廉政大讲堂->教育计划','11':'廉政大讲堂->文化展厅','6':'廉政大讲堂->他山之石','19':'廉政建设->政策法规->综合篇','20':'廉政建设->政策法规->教育篇',
'21':'廉政建设->政策法规->制度篇','22':'廉政建设->政策法规->监督篇','23':'廉政建设->政策法规->惩治篇','24':'廉政建设->政策法规->预防篇',
'25':'廉政建设->政策法规->纠风篇','16':'廉政建设->两权监督','17':'廉政建设->政风行风','18':'廉政建设->成果展示','26':'廉政文化->文化书架->清风书苑',
'27':'廉政文化->文化书架->格言警句','28':'廉政文化->文化书架->廉政画册','29':'廉政文化->文化书架->廉政书法','39':'廉政文化->文化书架->清风税廉','30':'廉政文化->廉政漫画','31':'廉政文化->动漫集锦',
'32':'廉政文化->经典红歌','33':'廉政文化->红色电影','34':'音视频课堂->工作视频','35':'音视频课堂->教育讲座','36':'音视频课堂->税官风采','37':'音视频课堂->反腐警示'}"/></td>
            <th nowrap>录入时间：</th>
            <td nowrap>
                <s:textfield name="startDate" id="startDate" cssClass="listinput" cssStyle="width:80px;" theme="simple" readonly="true" onclick="new Calendar(null, null, 0).show(this);"/> &nbsp;-&nbsp;
               <s:textfield name="endDate" id="endDate" cssClass="listinput" cssStyle="width:80px;" theme="simple" readonly="true" onclick="new Calendar(null, null, 0).show(this);"/>
            </td>
            <td>
                <button type="button" id="queryBt" style="width:50px;" class="button" onclick="doQuery()">查询</button>&nbsp;
            </td>
        </tr>
    </table>
    <s:if test="pageVO != null">
    <table width="98%" align="center" border="0" cellpadding="5" cellspacing="1" style="margin-bottom:8px;margin-top:8px;">
  <%--<tr>--%>
    <%--<td background="<c:url value='/frame/wbg.gif'/>" bgcolor="#EEF4EA" class='title'><span><img align="absmiddle" src="<c:url value='/frame/ico.jpg'/>" width="13" height="15">文章列表</span></td>--%>
  <%--</tr>--%>
  <tr bgcolor="#FFFFFF">
    <td align="center"><table width="100%"  border="0" cellpadding="0" cellspacing="0">
        <tr align="center" style="background-image:url(<c:url value='/frame/lititbg_06.jpg'/>) ">
            <th height="29" nowrap>标题</th>
            <th width="100" nowrap>录入时间</th>
            <th width="100" nowrap>录入人员</th>
            <th width="80" nowrap>查看</th>
            <th width="80" nowrap>排序</th>
        </tr>
        <%
            PageVO pagev = (PageVO)request.getAttribute("pageVO");
            List data = pagev.getDataList();
            int s = 1;
            if(pagev.getCurrentPage()==1) {
                s = 0;
            }
            int t = data.size()>20?data.size()-1:data.size();
            for(int a = s; a < t;a ++) {
                Map lastmap = new HashMap();
                if(a>0) lastmap = (Map)data.get(a-1);
                Map currmap = data.get(a)==null?new HashMap():(Map)data.get(a);
                Map nextmap = new HashMap();
                if(a < data.size()-1) nextmap = (Map)data.get(a+1);
                String lastId = lastmap.get("TYPEID")==null?"":(String)lastmap.get("TYPEID");
                String currId = currmap.get("TYPEID")==null?"":(String)currmap.get("TYPEID");
                String nextId = nextmap.get("TYPEID")==null?"":(String)nextmap.get("TYPEID");
        %>
      <tr class='tr<%=a%2%>' onMouseMove="javascript:this.bgColor='#ddf5d4';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
        <td height="29" align="left"><%=currmap.get("TITLE")%></td>
        <td align="center" nowrap><%=currmap.get("INSERTDATE")%></td>
        <td align="center" nowrap><%=currmap.get("USERNAME")%></td>
        <td align="center" nowrap>
                <a href="<c:url value='/viewArticleInfo.do?articleId='/><%=currmap.get("ID")%>&partType=<s:property value="partType"/>" target="_blank">[查看]</a>
      </td>
          <td align="center" nowrap>
                <img src="<c:url value='/images/up.png'/>" width="16" height="20" title="上移" style="cursor:pointer" onclick="changeOrder('<%=lastId%>','<%=currId%>')"/>
                <img src="<c:url value='/images/down.png'/>" width="16" height="20" title="下移" style="cursor:pointer" onclick="changeOrder('<%=currId%>','<%=nextId%>')"/>&nbsp;
      </td>
      </tr>
        <%
            }
        %>
        <tr style="height:26px;font-size: 12px;">
            <td colspan="5" style="padding-right:6px;text-align: right;">
                共<s:property value="%{pageVO.totalCount}"/>条
                共<s:property value="%{pageVO.totalPage}"/>页
                第<s:property value="%{pageVO.currentPage}"/>页
                <s:if test="%{pageVO.currentPage > 1}">
                    <a href="#" onclick='toPage(1);return false;'>[首页]</a>
                    <a href="#"
                       onclick='toPage(<s:property value="pageVO.priviousPage"/>);return false'>[上一页]</a>
                </s:if>
                <s:if test="%{pageVO.totalPage > pageVO.currentPage}">
                    <a href="#" onclick='toPage(<s:property value="pageVO.nextPage"/>);return false;'>[下一页]</a>
                    <a href="#" onclick='toPage(<s:property value="pageVO.totalPage"/>);return false;'>[尾页]</a>
                </s:if>
                <input name="goPage" type="text" class="listinput" style="width:28px;" size="1"/>&nbsp;
                <button type="button" class="button" style="width:32px;" onClick="jumpToPage()">GO</button>
                &nbsp;
            </td>
        </tr>
    </table>
        </s:if>
        <input type="hidden" name="changeId1" id="changeId1"/>
        <input type="hidden" name="changeId2" id="changeId2"/>
    </form>
</body>
<script language="javascript" src="<c:url value='/script/Calendar.js'/>"></script>
<script>
    parent._setHeight();

    function doQuery() {
        var sdate = document.getElementById("startDate").value;
		var edate = document.getElementById("endDate").value;
        var sempty = sdate=="";
        var eempty = edate=="";
        if(sempty != eempty) {
            alert("日期范围有误，请修改！");
            return;
        } else if(!sempty && sdate > edate) {
            alert("日期范围有误，请修改！");
            return;
        }
        document.forms[0].action="<c:url value='/system/queryOrderList.do?targerPageNum=1'/>";
        document.forms[0].submit();
    }

    function changeOrder(id1,id2){
        if(id1=="" || id2==""){
            return;
        }
        document.getElementById("changeId1").value = id1;
        document.getElementById("changeId2").value = id2;
        document.forms[0].action="<c:url value='/system/doChangeOrder.do?targerPageNum='/><s:property value="%{pageVO.currentPage}"/>";
        document.forms[0].submit();
    }

    function toPage(pageNum) {
        document.forms[0].action = "<c:url value='/system/queryOrderList.do?targerPageNum='/>"+ pageNum;
        document.forms[0].submit();
    }

    function jumpToPage() {
        var iForm = document.forms[0];
        if (iForm.goPage.value == "") {
            alert("请输入要跳转到的页数！");
            return;
        }
        if (isNaN(iForm.goPage.value)) {
            alert("页数只能为整数！");
            return;
        }
        var toPageNum = parseInt(iForm.goPage.value);
        if (toPageNum < 1 || toPageNum > <s:if test="%{pageVO.totalPage != null}"><s:property value="%{pageVO.totalPage}"/></s:if><s:else>1</s:else>) {
            alert("页数输入有误！");
            return;
        }
        toPage(toPageNum);
    }
</script>
</html>